<?php
/**
 * Created by PhpStorm.
 * User: home
 * Date: 2019/2/23
 * Time: 12:56
 */
include 'lib.php';
if (!isset($_GET['student_no']) || empty($_GET['student_no'])) {
    showMessage('请填写要查询的学号');
}
$student_no = intval($_GET['student_no']);
// 查询学生基本信息
$studentInfo = queryStudentInfo($student_no);
if (!$studentInfo) {
    showMessage('输入的学号不正确');
}
// 查询分数
$scoreArray = queryStudentScore($student_no);

?>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查询结果</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <h1 class="text-center mt-lg-5">查询结果</h1>

    <p class="text-center">
        学号: <span><?php echo $studentInfo['student_no']; ?></span>
        姓名: <span><?php echo $studentInfo['student_name']; ?></span>
        年级: <span><?php echo $studentInfo['student_grade']; ?></span>
    </p>
    <div class="text-center">
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>考试科目</th>
                <th>分数</th>
                <th>考试时间</th>
                <th>等级</th>
                <th>审核状态</th>
            </tr>
            </thead>
            <tbody>
            <?php
            if (count($scoreArray) == 0):
                ?>
                <tr>
                    <td colspan="5" class="text-center">没有查询到相关考试成绩</td>
                </tr>
            <?php
            else:
                foreach ($scoreArray as $score):
                    ?>
                    <tr>
                        <td><?= $score['exam_subject']; ?></td>
                        <td><?= $score['exam_score']; ?></td>
                        <td><?= $score['exam_date']; ?></td>
                        <td><?php
                            if ($score['exam_score'] >= 85) {
                                echo "优";
                            } elseif ($score['exam_score'] >= 75) {
                                echo "良";
                            }
                            if ($score['exam_score'] >= 60) {
                                echo "合格";
                            } else {
                                echo "不合格";
                            }
                            ?></td>
                        <td><?= $score['score_state'] == 1 ? '已审核' : '未审核'; ?></td>
                    </tr>
                <?php

                endforeach;
            endif;
            ?>
            </tbody>
        </table>
        <a href="index.php" class="text-info">返回重新查询</a>
    </div>
</div>
</body>
</html>
